package com.erp.erp_servers.Bank.imp;

import com.erp.erp_dao.Bank.IBankDAO;
import com.erp.erp_entitys.Bank.BankEntity;
import com.erp.erp_entitys.Bank.BankEntityExample;
import com.erp.erp_servers.Bank.IBankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName ImpBankService
 * @Description TODO
 * @Author songjizhen
 * @Date 2020-06-30 20:37
 * @Version 1.0
 */
@Service
public class ImpBankService implements IBankService {
    @Autowired
    IBankDAO bankDAO;
    /**
     * 新增银行帐号信息
     *
     * @param record
     * @return
     */
    @Override
    public int insertSelective(BankEntity record) {
       // bankDAO.insert(record);
        return bankDAO.insertSelective(record);
    }

    /**
     * 查询银行信息
     *
     * @param record
     * @return
     */
    @Override
    public List<BankEntity> selectByExample( BankEntity record) {
        BankEntityExample example=new BankEntityExample();
        BankEntityExample.Criteria criteria = example.createCriteria();
        criteria.andCompanyCodeEqualTo(record.getCompanyCode());
        List<BankEntity> bankEntities = bankDAO.selectByExample(example);
        return bankEntities;
    }

    @Override
    public BankEntity selectByPrimaryKey(Integer id) {
        return bankDAO.selectByPrimaryKey(id);
    }

    /**
     * 根据主键删除银行信息
     *
     * @param id
     * @return
     */
    @Override
    public int deleteByPrimaryKey(Integer id) {
        return bankDAO.deleteByPrimaryKey(id);
    }

    @Override
    public int deleteByExample(BankEntityExample example) {
        return bankDAO.deleteByExample(example);
    }

    /**
     * 更新银行信息
     *
     * @param record
     * @return
     */
    @Override
    public int updateByExampleSelective(BankEntity record) {
        BankEntityExample example=new BankEntityExample();
        BankEntityExample.Criteria criteria = example.createCriteria();
        criteria.andIdEqualTo(record.getId());
        int num = bankDAO.updateByExampleSelective(record, example);
        return num;
    }
}
